//
//  TouchView.m
//  03-UIResponder
//
//  Created by 曹曹 on 16/7/18.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "TouchView.h"

@implementation TouchView
/* 继承于UIResponder都有:
 Appdelegate UIView UIViewController
 1.重写touchesBegan:withEvent:方法，方法实现：NSLog输出指定方法（__Function__）
 2.重写touchesMove:withEvent:方法，方法实现：NSLog输出指定方法名（__Function_）
 3.重写touchesEnd:withEvent:方法，方法实现：NSLog输出指定方法名（__Function__）。
 并给当前视图的背景颜色设置为随机色。
 */
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //  nextResponder:下一级响应者
    NSLog(@"self.view = %@", self.nextResponder);
//    NSLog(@"ViewController = %@", self.nextResponder.nextResponder);
//    NSLog(@"Window = %@", self.nextResponder.nextResponder.nextResponder);
//    NSLog(@"UIApplication = %@", self.nextResponder.nextResponder.nextResponder.nextResponder);
//    NSLog(@"AppDelegate = %@", self.nextResponder.nextResponder.nextResponder.nextResponder.nextResponder);
//    NSLog(@"%@", self.nextResponder.nextResponder.nextResponder.nextResponder.nextResponder.nextResponder);
//    [super touchesBegan:touches withEvent:event];
//    NSLog(@"%@-------%s", self.class,  __FUNCTION__);
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1];
    //    [super touchesMoved:touches withEvent:event];
    //    NSLog(@"%@-------%s", self.class,  __FUNCTION__);
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //    [super touchesEnded:touches withEvent:event];
    //    NSLog(@"%@-------%s", self.class,  __FUNCTION__);
}

@end
